﻿namespace DoublePointers {
    public class LC0283 {
        public void MoveZeroes(int[] nums) {
            int N = nums.Length;
            int nZeros = 0;
            foreach (var num in nums) {
                if (num == 0) nZeros++;
            }

            int slotIndex = 0, pointer = 0;
            for (; pointer < N; pointer++) {
                if (nums[pointer] != 0) nums[slotIndex++] = nums[pointer];
            }

            while (slotIndex < N) nums[slotIndex++] = 0;
        }
    }
}